import { ReducersMapObject, Reducer } from 'redux';
import { connectRouter, LocationChangeAction } from 'connected-react-router';
import produce from 'immer';
import { combineReducers } from 'redux-immer';
import home from './home';
import history from '../../history';
import { CombinedState } from '../../typings';

// [K in keyof S]: Reducer<S[K], A>
const reducers: ReducersMapObject<CombinedState, LocationChangeAction> = {
  home,
  router: connectRouter(history),
};
const rootReducer: Reducer<CombinedState, any> = combineReducers <CombinedState>(produce, reducers);

export default rootReducer;
